home *** CD-ROM | disk | FTP | other *** search
/ Java Primer Plus / Java Primer Plus (Waite Group Proess)(1996).iso / java_Win / demo / SpreadSheet / Node.class (.txt) < prev    next >
Encoding:
Java Class File  |  1995-10-12  |  1.9 KB  |  64 lines

  1. class Node {
  2.    // $FF: renamed from: OP int
  3.    public static final int field_0 = 0;
  4.    public static final int VALUE = 1;
  5.    public static final int CELL = 2;
  6.    int type;
  7.    Node left;
  8.    Node right;
  9.    int row;
  10.    int column;
  11.    float value;
  12.    // $FF: renamed from: op char
  13.    char field_1;
  14.  
  15.    public Node() {
  16.       this.left = null;
  17.       this.right = null;
  18.       this.value = 0.0F;
  19.       this.row = -1;
  20.       this.column = -1;
  21.       this.field_1 = 0;
  22.       this.type = 1;
  23.    }
  24.  
  25.    public Node(Node n) {
  26.       this.left = n.left;
  27.       this.right = n.right;
  28.       this.value = n.value;
  29.       this.row = n.row;
  30.       this.column = n.column;
  31.       this.field_1 = n.field_1;
  32.       this.type = n.type;
  33.    }
  34.  
  35.    public void indent(int ind) {
  36.       for(int i = 0; i < ind; ++i) {
  37.          System.out.print(" ");
  38.       }
  39.  
  40.    }
  41.  
  42.    public void print(int indentLevel) {
  43.       char[] l = new char[1];
  44.       this.indent(indentLevel);
  45.       System.out.println("NODE type=" + this.type);
  46.       this.indent(indentLevel);
  47.       switch (this.type) {
  48.          case 0:
  49.             System.out.println(" op=" + this.field_1);
  50.             this.left.print(indentLevel + 3);
  51.             this.right.print(indentLevel + 3);
  52.             return;
  53.          case 1:
  54.             System.out.println(" value=" + this.value);
  55.             return;
  56.          case 2:
  57.             l[0] = (char)(65 + this.column);
  58.             System.out.println(" cell=" + new String(l) + (this.row + 1));
  59.             return;
  60.          default:
  61.       }
  62.    }
  63. }
  64.